package chapter09;

/**
 * Created by V5470-I5 on 2016/4/1.
 */
import java.util.*;
class Account2 implements Comparable<Account2>{
    private String name;
    private String number;
    private int balance;

    Account2(String name,String number,int balance){
        this.name=name;
        this.number=number;
        this.balance=balance;
    }
    @Override
    public String toString(){
        return String.format("Account(%s,%s,%d)",name,number,balance);
    }
@Override
    public int compareTo(Account2 other){
    return this.balance-other.balance;
}
}
public class Sort3 {
    public static void main(String[] args){
        List accounts=Arrays.asList(
                new Account("Messi","X1234",1000),
                new Account("Suares","X5678",500),
                new Account("Neymar","X2468",200)
        );
        Collections.sort(accounts);
        System.out.println(accounts);
    }
}

